/**
 *
 * This file is part of Tulip (www.tulip-software.org)
 *
 * Authors: David Auber and the Tulip development Team
 * from LaBRI, University of Bordeaux
 *
 * Tulip is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3
 * of the License, or (at your option) any later version.
 *
 * Tulip is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 */
#include <stdio.h>

struct X11Color {
  const char *  name;
  int       h, s, b;
} X11Clut[] = {
  {"aliceblue",147,15,255},
  {"antiquewhite",24,35,250},
  {"antiquewhite1",23,36,255},
  {"antiquewhite2",23,36,238},
  {"antiquewhite3",23,36,205},
  {"antiquewhite4",24,34,139},
  {"aquamarine",113,128,255},
  {"aquamarine1",113,128,255},
  {"aquamarine2",113,128,238},
  {"aquamarine3",113,128,205},
  {"aquamarine4",113,128,139},
  {"azure",127,15,255},
  {"azure1",127,15,255},
  {"azure2",127,15,238},
  {"azure3",127,14,205},
  {"azure4",127,14,139},
  {"beige",42,26,245},
  {"bisque",23,58,255},
  {"bisque1",23,58,255},
  {"bisque2",23,58,238},
  {"bisque3",22,58,205},
  {"bisque4",23,58,139},
  {"black",0,0,0},
  {"blanchedalmond",25,49,255},
  {"blue",170,255,255},
  {"blue1",170,255,255},
  {"blue2",170,255,238},
  {"blue3",170,255,205},
  {"blue4",170,255,139},
  {"blueviolet",192,206,226},
  {"brown",0,190,165},
  {"brown1",0,191,255},
  {"brown2",0,191,238},
  {"brown3",0,191,205},
  {"brown4",0,190,139},
  {"burlywood",23,99,222},
  {"burlywood1",23,100,255},
  {"burlywood2",23,99,238},
  {"burlywood3",23,99,205},
  {"burlywood4",23,99,139},
  {"cadetblue",128,103,160},
  {"cadetblue1",131,103,255},
  {"cadetblue2",131,102,238},
  {"cadetblue3",131,103,205},
  {"cadetblue4",131,102,139},
  {"chartreuse",63,255,255},
  {"chartreuse1",63,255,255},
  {"chartreuse2",63,255,238},
  {"chartreuse3",63,255,205},
  {"chartreuse4",63,255,139},
  {"chocolate",17,218,210},
  {"chocolate1",17,219,255},
  {"chocolate2",17,219,238},
  {"chocolate3",17,218,205},
  {"chocolate4",17,220,139},
  {"coral",11,175,255},
  {"coral1",7,169,255},
  {"coral2",6,169,238},
  {"coral3",6,169,205},
  {"coral4",6,168,139},
  {"cornflowerblue",154,147,237},
  {"cornsilk",33,34,255},
  {"cornsilk1",33,34,255},
  {"cornsilk2",34,35,238},
  {"cornsilk3",34,34,205},
  {"cornsilk4",35,34,139},
  {"crimson",246,231,220},
  {"cyan",127,255,255},
  {"cyan1",127,255,255},
  {"cyan2",127,255,238},
  {"cyan3",127,255,205},
  {"cyan4",127,255,139},
  {"darkgoldenrod",30,239,184},
  {"darkgoldenrod1",30,240,255},
  {"darkgoldenrod2",30,240,238},
  {"darkgoldenrod3",30,240,205},
  {"darkgoldenrod4",30,240,139},
  {"darkgreen",85,255,100},
  {"darkkhaki",39,110,189},
  {"darkolivegreen",58,142,107},
  {"darkolivegreen1",58,143,255},
  {"darkolivegreen2",58,143,238},
  {"darkolivegreen3",58,143,205},
  {"darkolivegreen4",58,143,139},
  {"darkorange",23,255,255},
  {"darkorange1",21,255,255},
  {"darkorange2",21,255,238},
  {"darkorange3",21,255,205},
  {"darkorange4",21,255,139},
  {"darkorchid",198,192,204},
  {"darkorchid1",198,193,255},
  {"darkorchid2",198,192,238},
  {"darkorchid3",198,192,205},
  {"darkorchid4",198,192,139},
  {"darksalmon",10,121,233},
  {"darkseagreen",85,61,188},
  {"darkseagreen1",85,62,255},
  {"darkseagreen2",85,62,238},
  {"darkseagreen3",85,62,205},
  {"darkseagreen4",85,62,139},
  {"darkslateblue",175,143,139},
  {"darkslategray",127,103,79},
  {"darkslategray1",127,104,255},
  {"darkslategray2",127,103,238},
  {"darkslategray3",127,104,205},
  {"darkslategray4",127,104,139},
  {"darkslategrey",127,103,79},
  {"darkturquoise",128,255,209},
  {"darkviolet",199,255,211},
  {"deeppink",232,235,255},
  {"deeppink1",232,235,255},
  {"deeppink2",232,235,238},
  {"deeppink3",232,235,205},
  {"deeppink4",231,236,139},
  {"deepskyblue",138,255,255},
  {"deepskyblue1",138,255,255},
  {"deepskyblue2",138,255,238},
  {"deepskyblue3",138,255,205},
  {"deepskyblue4",138,255,139},
  {"dimgray",0,0,105},
  {"dimgrey",0,0,105},
  {"dodgerblue",148,225,255},
  {"dodgerblue1",148,225,255},
  {"dodgerblue2",148,225,238},
  {"dodgerblue3",148,225,205},
  {"dodgerblue4",148,225,139},
  {"firebrick",0,206,178},
  {"firebrick1",0,207,255},
  {"firebrick2",0,207,238},
  {"firebrick3",0,207,205},
  {"firebrick4",0,207,139},
  {"floralwhite",28,15,255},
  {"forestgreen",85,192,139},
  {"gainsboro",0,0,220},
  {"ghostwhite",170,7,255},
  {"gold",35,255,255},
  {"gold1",35,255,255},
  {"gold2",35,255,238},
  {"gold3",35,255,205},
  {"gold4",35,255,139},
  {"goldenrod",30,217,218},
  {"goldenrod1",30,218,255},
  {"goldenrod2",30,218,238},
  {"goldenrod3",30,218,205},
  {"goldenrod4",30,218,139},
  {"gray",0,0,192},
  {"gray0",0,0,0},
  {"gray1",0,0,3},
  {"gray10",0,0,26},
  {"gray100",0,0,255},
  {"gray11",0,0,28},
  {"gray12",0,0,31},
  {"gray13",0,0,33},
  {"gray14",0,0,36},
  {"gray15",0,0,38},
  {"gray16",0,0,41},
  {"gray17",0,0,43},
  {"gray18",0,0,46},
  {"gray19",0,0,48},
  {"gray2",0,0,5},
  {"gray20",0,0,51},
  {"gray21",0,0,54},
  {"gray22",0,0,56},
  {"gray23",0,0,59},
  {"gray24",0,0,61},
  {"gray25",0,0,64},
  {"gray26",0,0,66},
  {"gray27",0,0,69},
  {"gray28",0,0,71},
  {"gray29",0,0,74},
  {"gray3",0,0,8},
  {"gray30",0,0,77},
  {"gray31",0,0,79},
  {"gray32",0,0,82},
  {"gray33",0,0,84},
  {"gray34",0,0,87},
  {"gray35",0,0,89},
  {"gray36",0,0,92},
  {"gray37",0,0,94},
  {"gray38",0,0,97},
  {"gray39",0,0,99},
  {"gray4",0,0,10},
  {"gray40",0,0,102},
  {"gray41",0,0,105},
  {"gray42",0,0,107},
  {"gray43",0,0,110},
  {"gray44",0,0,112},
  {"gray45",0,0,115},
  {"gray46",0,0,117},
  {"gray47",0,0,120},
  {"gray48",0,0,122},
  {"gray49",0,0,125},
  {"gray5",0,0,13},
  {"gray50",0,0,127},
  {"gray51",0,0,130},
  {"gray52",0,0,133},
  {"gray53",0,0,135},
  {"gray54",0,0,138},
  {"gray55",0,0,140},
  {"gray56",0,0,143},
  {"gray57",0,0,145},
  {"gray58",0,0,148},
  {"gray59",0,0,150},
  {"gray6",0,0,15},
  {"gray60",0,0,153},
  {"gray61",0,0,156},
  {"gray62",0,0,158},
  {"gray63",0,0,161},
  {"gray64",0,0,163},
  {"gray65",0,0,166},
  {"gray66",0,0,168},
  {"gray67",0,0,171},
  {"gray68",0,0,173},
  {"gray69",0,0,176},
  {"gray7",0,0,18},
  {"gray70",0,0,179},
  {"gray71",0,0,181},
  {"gray72",0,0,184},
  {"gray73",0,0,186},
  {"gray74",0,0,189},
  {"gray75",0,0,191},
  {"gray76",0,0,194},
  {"gray77",0,0,196},
  {"gray78",0,0,199},
  {"gray79",0,0,201},
  {"gray8",0,0,20},
  {"gray80",0,0,204},
  {"gray81",0,0,207},
  {"gray82",0,0,209},
  {"gray83",0,0,212},
  {"gray84",0,0,214},
  {"gray85",0,0,217},
  {"gray86",0,0,219},
  {"gray87",0,0,222},
  {"gray88",0,0,224},
  {"gray89",0,0,227},
  {"gray9",0,0,23},
  {"gray90",0,0,229},
  {"gray91",0,0,232},
  {"gray92",0,0,235},
  {"gray93",0,0,237},
  {"gray94",0,0,240},
  {"gray95",0,0,242},
  {"gray96",0,0,245},
  {"gray97",0,0,247},
  {"gray98",0,0,250},
  {"gray99",0,0,252},
  {"green",85,255,255},
  {"green1",85,255,255},
  {"green2",85,255,238},
  {"green3",85,255,205},
  {"green4",85,255,139},
  {"greenyellow",59,208,255},
  {"grey",0,0,192},
  {"grey0",0,0,0},
  {"grey1",0,0,3},
  {"grey10",0,0,26},
  {"grey100",0,0,255},
  {"grey11",0,0,28},
  {"grey12",0,0,31},
  {"grey13",0,0,33},
  {"grey14",0,0,36},
  {"grey15",0,0,38},
  {"grey16",0,0,41},
  {"grey17",0,0,43},
  {"grey18",0,0,46},
  {"grey19",0,0,48},
  {"grey2",0,0,5},
  {"grey20",0,0,51},
  {"grey21",0,0,54},
  {"grey22",0,0,56},
  {"grey23",0,0,59},
  {"grey24",0,0,61},
  {"grey25",0,0,64},
  {"grey26",0,0,66},
  {"grey27",0,0,69},
  {"grey28",0,0,71},
  {"grey29",0,0,74},
  {"grey3",0,0,8},
  {"grey30",0,0,77},
  {"grey31",0,0,79},
  {"grey32",0,0,82},
  {"grey33",0,0,84},
  {"grey34",0,0,87},
  {"grey35",0,0,89},
  {"grey36",0,0,92},
  {"grey37",0,0,94},
  {"grey38",0,0,97},
  {"grey39",0,0,99},
  {"grey4",0,0,10},
  {"grey40",0,0,102},
  {"grey41",0,0,105},
  {"grey42",0,0,107},
  {"grey43",0,0,110},
  {"grey44",0,0,112},
  {"grey45",0,0,115},
  {"grey46",0,0,117},
  {"grey47",0,0,120},
  {"grey48",0,0,122},
  {"grey49",0,0,125},
  {"grey5",0,0,13},
  {"grey50",0,0,127},
  {"grey51",0,0,130},
  {"grey52",0,0,133},
  {"grey53",0,0,135},
  {"grey54",0,0,138},
  {"grey55",0,0,140},
  {"grey56",0,0,143},
  {"grey57",0,0,145},
  {"grey58",0,0,148},
  {"grey59",0,0,150},
  {"grey6",0,0,15},
  {"grey60",0,0,153},
  {"grey61",0,0,156},
  {"grey62",0,0,158},
  {"grey63",0,0,161},
  {"grey64",0,0,163},
  {"grey65",0,0,166},
  {"grey66",0,0,168},
  {"grey67",0,0,171},
  {"grey68",0,0,173},
  {"grey69",0,0,176},
  {"grey7",0,0,18},
  {"grey70",0,0,179},
  {"grey71",0,0,181},
  {"grey72",0,0,184},
  {"grey73",0,0,186},
  {"grey74",0,0,189},
  {"grey75",0,0,191},
  {"grey76",0,0,194},
  {"grey77",0,0,196},
  {"grey78",0,0,199},
  {"grey79",0,0,201},
  {"grey8",0,0,20},
  {"grey80",0,0,204},
  {"grey81",0,0,207},
  {"grey82",0,0,209},
  {"grey83",0,0,212},
  {"grey84",0,0,214},
  {"grey85",0,0,217},
  {"grey86",0,0,219},
  {"grey87",0,0,222},
  {"grey88",0,0,224},
  {"grey89",0,0,227},
  {"grey9",0,0,23},
  {"grey90",0,0,229},
  {"grey91",0,0,232},
  {"grey92",0,0,235},
  {"grey93",0,0,237},
  {"grey94",0,0,240},
  {"grey95",0,0,242},
  {"grey96",0,0,245},
  {"grey97",0,0,247},
  {"grey98",0,0,250},
  {"grey99",0,0,252},
  {"honeydew",85,15,255},
  {"honeydew1",85,15,255},
  {"honeydew2",85,15,238},
  {"honeydew3",85,14,205},
  {"honeydew4",85,14,139},
  {"hotpink",233,150,255},
  {"hotpink1",234,145,255},
  {"hotpink2",235,141,238},
  {"hotpink3",236,135,205},
  {"hotpink4",234,148,139},
  {"indianred",0,140,205},
  {"indianred1",0,148,255},
  {"indianred2",0,148,238},
  {"indianred3",0,149,205},
  {"indianred4",0,148,139},
  {"indigo",194,255,130},
  {"ivory",42,15,255},
  {"ivory1",42,15,255},
  {"ivory2",42,15,238},
  {"ivory3",42,14,205},
  {"ivory4",42,14,139},
  {"khaki",38,106,240},
  {"khaki1",39,112,255},
  {"khaki2",39,112,238},
  {"khaki3",39,111,205},
  {"khaki4",39,111,139},
  {"lavender",170,20,250},
  {"lavenderblush",240,15,255},
  {"lavenderblush1",240,15,255},
  {"lavenderblush2",239,15,238},
  {"lavenderblush3",240,14,205},
  {"lavenderblush4",239,14,139},
  {"lawngreen",64,255,252},
  {"lemonchiffon",38,49,255},
  {"lemonchiffon1",38,49,255},
  {"lemonchiffon2",37,50,238},
  {"lemonchiffon3",38,49,205},
  {"lemonchiffon4",39,49,139},
  {"lightblue",137,63,230},
  {"lightblue1",138,64,255},
  {"lightblue2",138,64,238},
  {"lightblue3",138,63,205},
  {"lightblue4",137,64,139},
  {"lightcoral",0,119,240},
  {"lightcyan",127,31,255},
  {"lightcyan1",127,31,255},
  {"lightcyan2",127,31,238},
  {"lightcyan3",127,31,205},
  {"lightcyan4",127,31,139},
  {"lightgoldenrod",35,115,238},
  {"lightgoldenrod1",35,116,255},
  {"lightgoldenrod2",35,115,238},
  {"lightgoldenrod3",35,115,205},
  {"lightgoldenrod4",35,115,139},
  {"lightgoldenrodyellow",42,40,250},
  {"lightgray",0,0,211},
  {"lightgrey",0,0,211},
  {"lightpink",248,73,255},
  {"lightpink1",249,81,255},
  {"lightpink2",248,81,238},
  {"lightpink3",249,80,205},
  {"lightpink4",249,80,139},
  {"lightsalmon",12,132,255},
  {"lightsalmon1",12,132,255},
  {"lightsalmon2",11,132,238},
  {"lightsalmon3",12,133,205},
  {"lightsalmon4",12,133,139},
  {"lightseagreen",125,209,178},
  {"lightskyblue",143,117,250},
  {"lightskyblue1",143,79,255},
  {"lightskyblue2",143,79,238},
  {"lightskyblue3",142,79,205},
  {"lightskyblue4",143,78,139},
  {"lightslateblue",175,143,255},
  {"lightslategray",148,56,153},
  {"lightslategrey",148,56,153},
  {"lightsteelblue",151,52,222},
  {"lightsteelblue1",151,53,255},
  {"lightsteelblue2",151,53,238},
  {"lightsteelblue3",151,53,205},
  {"lightsteelblue4",150,53,139},
  {"lightyellow",42,31,255},
  {"lightyellow1",42,31,255},
  {"lightyellow2",42,31,238},
  {"lightyellow3",42,31,205},
  {"lightyellow4",42,31,139},
  {"limegreen",85,192,205},
  {"linen",21,20,250},
  {"magenta",212,255,255},
  {"magenta1",212,255,255},
  {"magenta2",212,255,238},
  {"magenta3",212,255,205},
  {"magenta4",212,255,139},
  {"maroon",239,185,176},
  {"maroon1",228,203,255},
  {"maroon2",228,203,238},
  {"maroon3",228,204,205},
  {"maroon4",228,203,139},
  {"mediumaquamarine",113,128,205},
  {"mediumblue",170,255,205},
  {"mediumorchid",204,152,211},
  {"mediumorchid1",203,153,255},
  {"mediumorchid2",203,153,238},
  {"mediumorchid3",203,153,205},
  {"mediumorchid4",203,154,139},
  {"mediumpurple",183,124,219},
  {"mediumpurple1",183,125,255},
  {"mediumpurple2",183,125,238},
  {"mediumpurple3",183,125,205},
  {"mediumpurple4",183,124,139},
  {"mediumseagreen",103,169,179},
  {"mediumslateblue",176,143,238},
  {"mediumspringgreen",111,255,250},
  {"mediumturquoise",125,167,209},
  {"mediumvioletred",228,228,199},
  {"midnightblue",170,198,112},
  {"mintcream",106,9,255},
  {"mistyrose",4,30,255},
  {"mistyrose1",4,30,255},
  {"mistyrose2",4,30,238},
  {"mistyrose3",3,29,205},
  {"mistyrose4",5,29,139},
  {"moccasin",26,73,255},
  {"navajowhite",25,81,255},
  {"navajowhite1",25,81,255},
  {"navajowhite2",25,82,238},
  {"navajowhite3",25,82,205},
  {"navajowhite4",25,82,139},
  {"navy",170,255,128},
  {"navyblue",170,255,128},
  {"oldlace",27,23,253},
  {"olivedrab",56,192,142},
  {"olivedrab1",56,193,255},
  {"olivedrab2",56,192,238},
  {"olivedrab3",56,192,205},
  {"olivedrab4",56,192,139},
  {"orange",27,255,255},
  {"orange1",27,255,255},
  {"orange2",27,255,238},
  {"orange3",27,255,205},
  {"orange4",27,255,139},
  {"orangered",11,255,255},
  {"orangered1",11,255,255},
  {"orangered2",11,255,238},
  {"orangered3",11,255,205},
  {"orangered4",11,255,139},
  {"orchid",214,123,218},
  {"orchid1",214,124,255},
  {"orchid2",214,124,238},
  {"orchid3",214,124,205},
  {"orchid4",213,124,139},
  {"palegoldenrod",38,72,238},
  {"palegreen",85,100,251},
  {"palegreen1",85,101,255},
  {"palegreen2",85,100,238},
  {"palegreen3",85,100,205},
  {"palegreen4",85,100,139},
  {"paleturquoise",127,67,238},
  {"paleturquoise1",127,68,255},
  {"paleturquoise2",127,68,238},
  {"paleturquoise3",127,68,205},
  {"paleturquoise4",127,67,139},
  {"palevioletred",241,124,219},
  {"palevioletred1",241,125,255},
  {"palevioletred2",241,125,238},
  {"palevioletred3",241,125,205},
  {"palevioletred4",241,124,139},
  {"papayawhip",26,41,255},
  {"peachpuff",20,70,255},
  {"peachpuff1",20,70,255},
  {"peachpuff2",19,69,238},
  {"peachpuff3",19,69,205},
  {"peachpuff4",20,69,139},
  {"peru",20,176,205},
  {"pink",247,63,255},
  {"pink1",245,73,255},
  {"pink2",245,73,238},
  {"pink3",245,74,205},
  {"pink4",245,73,139},
  {"plum",212,70,221},
  {"plum1",212,68,255},
  {"plum2",212,68,238},
  {"plum3",212,68,205},
  {"plum4",212,67,139},
  {"powderblue",132,59,230},
  {"purple",196,221,240},
  {"purple1",191,207,255},
  {"purple2",192,207,238},
  {"purple3",192,207,205},
  {"purple4",192,207,139},
  {"red",0,255,255},
  {"red1",0,255,255},
  {"red2",0,255,238},
  {"red3",0,255,205},
  {"red4",0,255,139},
  {"rosybrown",0,61,188},
  {"rosybrown1",0,62,255},
  {"rosybrown2",0,62,238},
  {"rosybrown3",0,62,205},
  {"rosybrown4",0,62,139},
  {"royalblue",159,181,225},
  {"royalblue1",159,183,255},
  {"royalblue2",159,183,238},
  {"royalblue3",159,182,205},
  {"royalblue4",159,183,139},
  {"saddlebrown",17,220,139},
  {"salmon",4,138,250},
  {"salmon1",9,150,255},
  {"salmon2",9,150,238},
  {"salmon3",9,150,205},
  {"salmon4",9,150,139},
  {"sandybrown",19,154,244},
  {"seagreen",103,170,139},
  {"seagreen1",103,171,255},
  {"seagreen2",103,171,238},
  {"seagreen3",103,171,205},
  {"seagreen4",103,170,139},
  {"seashell",17,16,255},
  {"seashell1",17,16,255},
  {"seashell2",18,17,238},
  {"seashell3",18,17,205},
  {"seashell4",18,16,139},
  {"sienna",13,183,160},
  {"sienna1",13,184,255},
  {"sienna2",13,184,238},
  {"sienna3",13,184,205},
  {"sienna4",13,185,139},
  {"skyblue",139,108,235},
  {"skyblue1",144,120,255},
  {"skyblue2",144,120,238},
  {"skyblue3",144,120,205},
  {"skyblue4",145,119,139},
  {"slateblue",175,143,205},
  {"slateblue1",175,144,255},
  {"slateblue2",175,144,238},
  {"slateblue3",175,144,205},
  {"slateblue4",175,144,139},
  {"slategray",148,56,144},
  {"slategray1",149,56,255},
  {"slategray2",149,56,238},
  {"slategray3",148,57,205},
  {"slategray4",149,56,139},
  {"slategrey",148,56,144},
  {"snow",0,5,255},
  {"snow1",0,5,255},
  {"snow2",0,5,238},
  {"snow3",0,4,205},
  {"snow4",0,3,139},
  {"springgreen",106,255,255},
  {"springgreen1",106,255,255},
  {"springgreen2",106,255,238},
  {"springgreen3",106,255,205},
  {"springgreen4",106,255,139},
  {"steelblue",146,155,180},
  {"steelblue1",146,156,255},
  {"steelblue2",146,156,238},
  {"steelblue3",146,156,205},
  {"steelblue4",147,155,139},
  {"tan",24,84,210},
  {"tan1",20,176,255},
  {"tan2",20,176,238},
  {"tan3",20,176,205},
  {"tan4",20,176,139},
  {"thistle",212,29,216},
  {"thistle1",212,30,255},
  {"thistle2",212,30,238},
  {"thistle3",212,29,205},
  {"thistle4",212,29,139},
  {"tomato",6,184,255},
  {"tomato1",6,184,255},
  {"tomato2",6,184,238},
  {"tomato3",6,184,205},
  {"tomato4",6,185,139},
  {"turquoise",123,182,224},
  {"turquoise1",129,255,255},
  {"turquoise2",129,255,238},
  {"turquoise3",129,255,205},
  {"turquoise4",129,255,139},
  {"violet",212,115,238},
  {"violetred",227,215,208},
  {"violetred1",235,193,255},
  {"violetred2",235,192,238},
  {"violetred3",235,192,205},
  {"violetred4",235,192,139},
  {"wheat",27,68,245},
  {"wheat1",27,69,255},
  {"wheat2",27,68,238},
  {"wheat3",27,68,205},
  {"wheat4",27,67,139},
  {"white",0,0,255},
  {"whitesmoke",0,0,245},
  {"yellow",42,255,255},
  {"yellow1",42,255,255},
  {"yellow2",42,255,238},
  {"yellow3",42,255,205},
  {"yellow4",42,255,139},
  {"yellowgreen",56,192,205},
};



void HSBtoRGB(  float  inH,  float  inS,  float  inB,
                float& outR, float& outG, float& outB ) {
  if( inS == 0.0f ) {
    outR = outG = outB = inB * 255.0f;
  }
  else {
    float _h = inH * 6.0f,
          _i = int( _h ),
          _1 = inB * ( 1.0f - inS ),
          _2 = inB * ( 1.0f - inS*(_h-_i) ),
          _3 = inB * ( 1.0f - inS*(1.0f-(_h-_i)) );

    switch( int(_i) ) {
    case 0 :
      outR = inB*255.0f;
      outG = _3*255.0f;
      outB = _1*255.0f;
      break;

    case 1 :
      outR = _2*255.0f;
      outG = inB*255.0f;
      outB = _1*255.0f;
      break;

    case 2 :
      outR = _1*255.0f;
      outG = inB*255.0f;
      outB = _3*255.0f;
      break;

    case 3 :
      outR = _1*255.0f;
      outG = _2*255.0f;
      outB = inB*255.0f;
      break;

    case 4 :
      outR = _3*255.0f;
      outG = _1*255.0f;
      outB = inB*255.0f;
      break;

    default :
      outR = inB*255.0f;
      outG = _1*255.0f;
      outB = _2*255.0f;
      break;
    }
  }
}


bool DecodeColor  ( tlp::Color        & outColor,
                    const std::string & inValue   ) {
  // #RRGGBB ?
  {
    if( inValue.size() >= 7 && inValue[0] == '#' ) {
      unsigned int r, g, b;
      int n = sscanf( inValue.c_str(), "#%02x%02x%02x", &r, &g, &b );

      if( n == 3 ) {
        outColor = tlp::Color(r,g,b);
        return true;
      }
      else
        return false;
    }
  }

  // %f,%f,%f ?
  {
    float r, g, b;
    int n = sscanf( inValue.c_str(), "%f,%f,%f", &r, &g, &b );

    if( n == 3 ) {
      outColor = tlp::Color((unsigned int)(r*255.0f),(unsigned int)(g*255.0f),(unsigned int)(b*255.0f));
      return true;
    }
  }

  // %f %f %f ?
  {
    float r, g, b;
    int n = sscanf( inValue.c_str(), "%f %f %f", &r, &g, &b );

    if( n == 3 ) {
      outColor = tlp::Color((unsigned int)(r*255.0f),(unsigned int)(g*255.0f),(unsigned int)(b*255.0f));
      return true;
    }
  }

  // x11 name ?
  {
    unsigned int N = sizeof(X11Clut) / sizeof(X11Color);

    for( unsigned int i = 0 ; i < N ; i++ ) {
      if( strcasecmp(inValue.c_str(),X11Clut[i].name) == 0 ) {
        float r,g,b;
        HSBtoRGB( float(X11Clut[i].h)/255.0f,
                  float(X11Clut[i].s)/255.0f,
                  float(X11Clut[i].b)/255.0f,
                  r, g ,b );
        outColor = tlp::Color((unsigned int)(r),(unsigned int)(g),(unsigned int)(b));
        return true;
      }
    }
  }

  return false;
}



